﻿using System;
using System.Linq.Expressions;
using Domain.Core.Specification;
using Domain.MainModule.Entities;

namespace Domain.MainModule.Identities
{
    public class IdentityUserIdSpecification : Specification<Identity>
    {
        #region public properties

        public Guid MembershipUserId
        {
            get;
            set;
        }

        #endregion

        #region constructor

        public IdentityUserIdSpecification(Guid membershipUserId)
        {
            this.MembershipUserId = membershipUserId;
        }

        #endregion

        #region public methods

        public override Expression<Func<Identity, bool>> SatisfiedBy()
        {
            Specification<Identity> spec = new TrueSpecification<Identity>();
            spec &= new DirectSpecification<Identity>(c => c.UserId == this.MembershipUserId);

            return spec.SatisfiedBy();
        }

        #endregion
    }
}
                                 